


//将三维xyz坐标坐标转变为数组
function pointsToVertices8(points){
    if(null==points || typeof(points)=='undefined' || !(points instanceof Array)){
        return null
    }
    var x,y,z
    var iSize = points.length;
    var vertices = new Float32Array(24);
    var iIdx,point
    var pIdx = 0
    for(iIdx=0;iIdx<iSize;iIdx++){
        point = points[iIdx];
        if(null==point || typeof(point)=='undefined'){
            continue
        }
        x = point.x
        y = point.y
        z = point.z
        if(z ==null || typeof(z)=='undefined'){
            z = 0
        }
        vertices[pIdx++]= x;
        vertices[pIdx++]= y;
        vertices[pIdx++]= z;
    }
    return vertices
}

//显示顶点坐标
function showVertices(vertices){
    if(vertices==null ||typeof(vertices)=='undefined'){
        return
    }
    var iSize = 0
    if(vertices instanceof Float32Array){
        iSize = vertices.length
    }
    var idx = 0
    var expr = ''
    var tmp = ''
    console.log('showVertices iSize=',iSize)
    while(idx<iSize){
        expr = ''
        for(var i=0;i<4;i++){
            tmp = ''
            if(idx<iSize){
                if(tmp!=''){
                    tmp += ','
                }
                tmp += vertices[idx++]
            }
            if(idx<iSize){
                if(tmp!=''){
                    tmp += ','
                }
                tmp += vertices[idx++]
            }
            if(idx<iSize){
                if(tmp!=''){
                    tmp += ','
                }
                tmp += vertices[idx++]
            }
            if(tmp!=''){
                if(expr!=''){
                    expr += ','
                }
                expr += '('+tmp + ')'
            }
        }
        if(expr!=''){
            console.log(expr)
        }
    }
}
//显示顶点坐标
function showVerticesEx(vertices){
    if(vertices==null ||typeof(vertices)=='undefined'){
        return
    }
    var iSize = 0
    if(vertices instanceof Float32Array){
        iSize = vertices.length
    }
    var idx = 0
    var expr = ''
    var tmp = ''
    while(idx<iSize){
        expr += vertices[idx++] + ','
        if(idx>0 && idx%3==0){
            console.log(expr)
            expr = ''
        }
    }
    if(expr!=''){
        console.log(expr)
    }
    
}
function getDatetime() {
    const now = new Date();

    const year = now.getFullYear();
    const month = ('0' + (now.getMonth() + 1)).slice(-2);
    const day = ('0' + now.getDate()).slice(-2);
    const hours = ('0' + now.getHours()).slice(-2);
    const minutes = ('0' + now.getMinutes()).slice(-2);
    const seconds = ('0' + now.getSeconds()).slice(-2);

    const formattedTime = year + month + day + ' ' + hours +':' +  minutes+':' + seconds;

    return formattedTime;
}